#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5;
typedef long long LL;
LL n,d;
bool solve(LL p){
    if(p<d)return false;
    else if(p==d) return true;
    while(p>0){
        p-=d;
        if(p%10==0) return true;
    }
    if(p!=0) return false;
    else if(p==0) return true;
}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    cin>>n>>d;
    for(LL i=1;i<=n;i++){
        LL x;cin>>x;
        if(x>=d*10){
            cout<<"YES"<<endl;
        }
        else{
            if(solve(x)) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
  }
return 0;
}
